<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../../lib/innerIframe-include-ext.js"></script>
<script type="text/javascript" src="../../lib/loader-theme.js"></script>
<script type="text/javascript" src="../../lib/ext/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../lib/ext/plugins/DataTip.js"></script>
<script type="text/javascript" src="../../js/moment.min.js"></script>
<title>用户积分管理</title>
</head>
<script type="text/javascript">
Ext.require(['*']);
Ext.onReady(function(){
    Ext.QuickTips.init();
    Ext.define('model', {
        extend: 'Ext.data.Model',
        fields: [
            'id','user_id','user_type','current_amount','frozen_amount','status','create_at','update_at'
        ],
        idProperty: 'id'
    });
    
    var store = Ext.create('Ext.data.Store', {
        pageSize: 20,
        model: 'model',
        remoteSort: true,
        proxy: {
            type: 'ajax',
            method: 'GET',
            url: '/user/list',
            reader: {
                type: 'json',
                root: 'data',
                totalProperty: 'count'
            },
            simpleSortMode: true
        },
        sorters: [
            {
                property: 'id',
                direction: 'DESC'
            }
        ]
    });
    
    var grid = Ext.create('Ext.grid.Panel', {
        id:'my_grid',
        store: store,
        loadMask: true,
        region: 'center',
        selModel: Ext.create('Ext.selection.CheckboxModel'),
        columns: [
            {
                text: "用户ID",
                dataIndex: 'id',
                hidden: true
            },{
                text: '用户标志',
                dataIndex:'user_id'
            },{
                text:'用户类型',
                dataIndex:'user_type',
                renderer:function(val) {
                    if(val == '1')
                        return '广发通';
                    else
                        return val;
                }
            },{
                text:'当前积分',
                dataIndex:'current_amount'
            },{
                text:'冻结积分',
                dataIndex:'frozen_amount'
            },{
                text:'状态',
                dataIndex:'status',
                renderer:function(val) {
                    if(val == '0')
                        return '正常';
                    else
                        return '禁用'
                }
            },{
                text:'创建日期',
                dataIndex:'create_at',
                renderer: function(val) {
                    return moment(val).format('YYYY-MM-DD');
                }
            },{
                text:'更新日期',
                dataIndex:'update_at',
                renderer: function(val) {
                    return moment(val).format('YYYY-MM-DD');
                }
            }
        ],
        bbar: Ext.create('Ext.PagingToolbar', {
            store: store,
            displayInfo: true,
            displayMsg: '当前显示  {0} - {1} 共  {2} 条',
            emptyMsg: "没有数据显示！",
            beforePageText: "页码",
            afterPageText: "共 {0} 页",
            firstText:"首页",
            lastText:"末页",
            nextText:"下一页",
            prevText:"上一页",
            refreshText:"刷新"
        }),
        tbar: [
            {
                icon : '../../img/add.png',
                text: "添  加",
                disable:false,
                hidden:true
            },{
                icon : '../../img/edit.png',
                text: "修  改",
                disable:false,
                hidden:true
            },{
                icon : '../../img/delete.png',
                text : '删  除',
                disable:false,
                hidden:true
            }]
    });
    store.loadPage(1);
    
    var viewport = Ext.create('Ext.Viewport', {
        id: 'border-example',
        layout: 'fit',
        items: grid
    });
});
</script>
<body>
</body>
</html>